package numhashmap;

import java.util.*;

public class NumHashMap {
    HashMap<Character, Character> hmap = new HashMap<Character, Character>();
    private String string;

    NumHashMap() {
        hmap.put('v', 'a');
        hmap.put('e', 'b');
        hmap.put('k', 'c');
        hmap.put('n', 'd');
        hmap.put('o', 'e');
        hmap.put('h', 'f');
        hmap.put('z', 'g');
        hmap.put('f', 'h');
        hmap.put('a', 'i');
        hmap.put('l', 'j');
        hmap.put('j', 'k');
        hmap.put('x', 'l');
        hmap.put('d', 'm');
        hmap.put('m', 'n');
        hmap.put('y', 'o');
        hmap.put('g', 'p');
        hmap.put('b', 'q');
        hmap.put('r', 'r');
        hmap.put('c', 's');
        hmap.put('s', 't');
        hmap.put('w', 'u');
        hmap.put('q', 'v');
        hmap.put('u', 'w');
        hmap.put('p', 'x');
        hmap.put('t', 'y');
        hmap.put('i', 'z');
        HashMap hmap_copy = (HashMap) hmap.clone();
        Iterator<Character> lowerkeys = hmap_copy.keySet().iterator();
        Character c;
        while (lowerkeys.hasNext()) {
            c = lowerkeys.next();
            hmap.put((char) (c - 32), (char) (hmap.get(c) - 32));
        }
    }

    String decrypt(String originalstr) {
        String result = "";
        for (int i = 0; i < originalstr.length(); i++) {
            char c = originalstr.charAt(i);
            if (hmap.containsKey(c)) {
                result += String.valueOf(hmap.get(c));
            } else {
                result += String.valueOf(c);
            }
        }
        return result;
    }
}
